<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2010-12-9
 * Time: 20:19:04
 * To change this template use File | Settings | File Templates.
 */
 
class otherComponents extends sfComponents
{
  public function executeCatalog(sfWebRequest $request)
  {
        $catalogs = Doctrine_Core::getTable("Catalog")
                      ->createQuery()
                      ->where("is_column_b=?","1")
                      ->orderBy("catalog_id asc")
                      ->execute();
        $this->html="";
        $i = 1;
        foreach($catalogs as $catalog)
        {

            $this->html = $this->html."<option value=\"".$catalog->getCatalogId()."\" ";

            if($this->selectedId == null)
            {
                if($i == 1)
                   $this->html = $this->html."selected=\"selected\" " ;
            }
            else
            {
                if($catalog->getCatalogId() == $this->selectedId)
                    $this->html = $this->html."selected=\"selected\" " ;
            }
            $this->html = $this->html.">".$catalog->getDescription()."</option>";
            $i++;
        }
    }

  public function executeContentCatalog()
  {
         if($this->contentTypeId == null)
             $this->contentTypeId = 1000;
         $catalogs = $this->getDataRows("select catalog_id, description, name from catalog where catalog_id in(select catalog_id from CatalogContentType where content_type_id=".$this->contentTypeId.")");
         $this->html = "";
         $i = 1;
        foreach($catalogs as $catalog)
        {
            $this->html = $this->html."<option value=\"".$catalog["catalog_id"]."\" ";
            if($this->selectedId == null)
            {
                if($i == 1)
                   $this->html = $this->html."selected=\"selected\" " ;
            }
            else
            {
                if($catalog["catalog_id"] == $this->selectedId)
                    $this->html = $this->html."selected=\"selected\" " ;
            }
            $this->html = $this->html.">".$catalog["description"]."</option>";
            $i++;
        }
    }

  public function executeFocus()
  {
      $this->focus = new FocusContent();
      if($this->focusId != null)
      {
          $this->focus = Doctrine_Core::getTable("FocusContent")->find($this->focusId);
      }
  }
  function getDataRows($sqlStr)
  {
        $dbBase = new DbBase();
        return $dbBase->getDataQuery($sqlStr);
  }


}
